﻿<!-- Views/Home/Login.cshtml - 简洁版登录页面 -->
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <tanitle>@WebApplication1.Utilities.LanguageManager.GetText("Login") - @WebApplication1.Utilities.LanguageManager.GetText("ExamSystem")</tanitle>
    <link href="~/Content/bootstrap.min.css" rel="stylesheet" />
    <style>
        body {
            background-color: #f8f9fa;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        .login-container {
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }

        .login-card {
            background: white;
            border-radius: 10px;
            box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 400px;
            padding: 40px;
        }

        .login-header {
            text-align: center;
            margin-bottom: 30px;
        }

       

        .login-header p {
            font-size: 1rem;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-label {
            font-weight: 500;
            color: #495057;
            margin-bottom: 5px;
            display: block;
        }

        .form-control {
            border-radius: 5px;
            padding: 12px 15px;
            border: 1px solid #ced4da;
            transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
        }

        .form-control:focus {
            border-color: #80bdff;
            box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
        }

        .btn-login {
            background-color: #007bff;
            border: none;
            border-radius: 5px;
            padding: 12px;
            font-weight: 500;
            width: 100%;
            transition: background-color 0.2s;
        }

        .btn-login:hover {
            background-color: #0056b3;
        }

        .language-selector {
            text-align: center;
            margin-top: 20px;
            padding-top: 20px;
            border-top: 1px solid #e9ecef;
        }

        .language-selector p {
            font-size: 0.9rem;
            margin-bottom: 10px;
        }

        .language-buttons {
            display: flex;
            justify-content: center;
            gap: 15px;
        }

        .lang-btn {
            background: transparent;
            border: 1px solid #007bff;
            color: #007bff;
            padding: 8px 20px;
            border-radius: 20px;
            cursor: pointer;
            font-size: 0.9rem;
            transition: all 0.2s;
        }

        .lang-btn:hover {
            background-color: #007bff;
            color: white;
        }

        .alert {
            border-radius: 5px;
            font-size: 0.9rem;
        }

        .input-icon {
            position: relative;
        }

        .input-icon .glyphicon {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: #6c757d;
        }

        .input-icon input {
            padding-left: 40px;
        }

        @@media (max-width: 576px) {
            .login-card {
                padding: 30px 20px;
            }

            .language-buttons {
                flex-direction: column;
                gap: 10px;
            }

            .lang-btn {
                width: 100%;
            }
        }
    </style>
</head>
<body>
    <div class="login-container">
        <div class="login-card">
            <div class="login-header">
                <h2>@WebApplication1.Utilities.LanguageManager.GetText("ExamSystem")</h2>
                <p>@WebApplication1.Utilities.LanguageManager.GetText("LoginMessage")</p>
            </div>

            @if (TempData["ErrorMessage"] != null)
            {
                <div class="alert alert-danger">
                    <i class="glyphicon glyphicon-exclamation-sign"></i>
                    @TempData["ErrorMessage"]
                </div>
            }

            @using (Html.BeginForm("Login", "ACCOUNT", FormMethod.Post))
            {
                @Html.AntiForgeryToken()

                <div class="form-group">
                    <label for="username" class="form-label">
                        @WebApplication1.Utilities.LanguageManager.GetText("UserName")
                    </label>
                    <div class="input-icon">
                        <i class="glyphicon glyphicon-user"></i>
                        <input type="text"
                               class="form-control"
                               id="username"
                               name="username"
                               placeholder="@WebApplication1.Utilities.LanguageManager.GetText("UserName")"
                               required>
                    </div>
                </div>

                <div class="form-group">
                    <label for="password" class="form-label">
                        @WebApplication1.Utilities.LanguageManager.GetText("Password")
                    </label>
                    <div class="input-icon">
                        <i class="glyphicon glyphicon-lock"></i>
                        <input type="password"
                               class="form-control"
                               id="password"
                               name="password"
                               placeholder="@WebApplication1.Utilities.LanguageManager.GetText("Password")"
                               required>
                    </div>
                </div>

                <!-- 语言选择器放在密码栏下方 -->
                <div class="language-selector">
                    <p>@WebApplication1.Utilities.LanguageManager.GetText("ChooseLanguage")</p>
                    <div class="language-buttons">
                        <button type="button" class="lang-btn" onclick="changeLanguage('zh-CN')">
                            中文
                        </button>
                        <button type="button" class="lang-btn" onclick="changeLanguage('vi-VN')">
                            Tiếng Việt
                        </button>
                    </div>
                </div>
                <br />
                <button type="submit" class="btn btn-login">
                    <i class="glyphicon glyphicon-log-in"></i>
                    @WebApplication1.Utilities.LanguageManager.GetText("Login")
                </button>
            }
        </div>
    </div>

    <script src="~/Scripts/jquery-3.6.0.min.js"></script>
    <script>
        function changeLanguage(lang) {
            // 发送 AJAX 请求更改语言
            $.post('@Url.Action("ChangeLanguage", "Base")', {
                lang: lang,
                returnUrl: window.location.pathname + window.location.search
            }, function() {
                // 刷新页面以应用新语言
                location.reload();
            }).fail(function() {
                // 如果 AJAX 失败，也刷新页面
                location.reload();
            });
        }

        // 页面加载时聚焦到用户名输入框
        $(document).ready(function() {
            $('#username').focus();

            // 支持回车键登录
            $('input').on('keypress', function(e) {
                if (e.which === 13) {
                    $('form').submit();
                }
            });
        });
    </script>
    <script src="~/Scripts/jquery-3.6.0.min.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>
</body>
</html>